<!--添加修改角色信息-->
<template>
  <a-modal v-model="showAddTable" :mask-closable="false" :closable="true" :width="900"
           title="入账详情"
           :maskClosable="false"
           :destroyOnClose="true">
      <a-table :columns="columns" :dataSource="detail" :rowKey="record => record.index" style="height: 400px;overflow-y: auto"
               :pagination="false">
        <span slot="index" slot-scope="text, record, index">
          {{index+1}}
        </span>
      </a-table>
  </a-modal>
</template>

<script>
import verify from 'libs/verify'

export default {
  name: 'entryInfo',
  components: {
  },
  data() {
    return {
      verify,
      form: this.$form.createForm(this),
      showAddTable: false,
      input: false,
      procureTime: '',
      materialList: '',
      rowIndex: 10,
      detail:[],
      detailObj:{
        rowIndex:0,
        orderCode:'',
        goodCode:'',
        goodName:'',
        goodNum:'',
        unitPrice:'',
        allPrice:'',
      },
      columns: [
        {title: '订单编号', dataIndex: 'orderCode', key: 'orderCode',width: '20%'},
        {title: '物料名称', dataIndex: 'goodName', key: 'goodName'},
        {title: '采购数量', dataIndex: 'goodNum', key: 'goodNum', width: '15%', scopedSlots: {customRender: 'goodNum'}},
        {title: '单价（元）', dataIndex: 'unitPrice', key: 'unitPrice', width: '15%', scopedSlots: {customRender: 'unitPrice'}},
        {title: '总价（元）', dataIndex: 'allPrice', key: 'allPrice', width: '20%'},
      ],
    }
  },
  computed: {
    materialSelectList() {
      return this.$store.state.materialManage.materialSelectList
    },
    formStyle() {
      return this.$store.state.common.formStyle
    }
  },
  props: {
  },
  watch: {},
  methods: {
    /**
     * Function    : showEdit
     * Description : 编辑时显示
     * Input       : opt单个所有数据
     * Return      : none
     */
    showModal(opt) {
      this.showAddTable = true
      this.id = opt.recordId
      this.rowIndex = 10
      this.detail=[]
      let _this = this;
      _this.$store.dispatch('getEntryInfo', {recordId: opt.recordId}).then(response => {
        let orderInfo = {}
        if (response.code === 0) {
          orderInfo = response.data
          this.detail = orderInfo.detail
          // _this.$nextTick(() => {
          //   _this.form.setFieldsValue(_this.$pick(orderInfo, [
          //     'name', 'orderCode', 'procureReason', 'purchaser','procureTime',
          //     'purchaserPhone', 'supplier', 'supplierPhone'
          //   ]))
          //   _this.form.setFieldsValue(_this.$pick({procureTime:_this.procureTime}, ['procureTime'
          //   ]))
          // })
        } else {
          _this.$message.error(response.message)
        }
      })

    },

    /**
     * Function    : cancelApply
     * Description : 取消弹出框
     * Input       : val
     * Return      : none
     */
    cancelApply() {
      this.showAddTable = false
      let _this = this
      setTimeout(function () {
        _this.form.resetFields()
      }, 100)
    },

  },

  created() {
  }
}
</script>

<style>
.ant-table-thead {
  position: sticky;
  top: 0px;
  z-index: 1;
}
</style>
